<script>
if(window.opener) {
    window.opener.location.reload(true);
    window.close()
  }
</script>
<h2>Client Login</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <% if devise_mapping.rememberable? -%>
    <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
  <% end -%>

  <div><%= f.submit "Sign in" %></div>
<% end %>

<%#Social Networking Sign-in%>

<a href="/auth/facebook" class="popup" title = "Sign In With Facebook"  data-width = 600, data-height = 400>
  <%= image_tag "/assets/login.png", :alt => "Facebook" %>
</a>

<br/>
<%= render  "shared/link" %>

<script type="text/javascript">

function popupCenter(url, width, height, name) {
  var left = (screen.width/2)-(width/2);
  var top = (screen.height/2)-(height/2);
  return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top);
}

$(".popup").click(function(e) {
  popupCenter($(this).attr("href"), $(this).attr("data-width"), $(this).attr("data-height"), "authPopup");
  e.stopPropagation(); return false;
});
$(".check_pop_up").click(function(e) {
  var anchor_tag = $(this).next();
  popupCenter(anchor_tag.attr("href"), anchor_tag.attr("data-width"), anchor_tag.attr("data-height"), "authPopup");
  e.stopPropagation(); 
return false;
});

</script>